import java.io.InputStream;
import java.net.InetAddress;
import java.net.Socket;

public class TCPClient {

    public static void main(String[] args) {

        Socket clientSocket;
        try {
            clientSocket = new Socket(InetAddress.getLocalHost(),7788);

            // 获取服务器端返回的数据
            InputStream is = clientSocket.getInputStream();
            byte[] buffer = new byte[1024];
            int len = is.read(buffer);
            while( len!=-1){
                System.out.println(new String(buffer,0,len));
                len = is.read(buffer);
            }

            // 关闭
            is.close();
            clientSocket.close();
        } catch (Exception e){
            e.printStackTrace();
        }
    }

}
